package com.jstyle.beatecg.util;

import android.content.Context;

import com.jstyle.beatecg.R;
import com.jstyle.beatecg.daoManager.UserInfoDaoManager;
import com.jstyle.beatecg.model.UserInfo;


public class ReportDetail {
	// 交感副交感
	public static String getSympathetic(float hrv, Context context) {
		String asser1 = "";
		if (hrv <= 1.0) {
			asser1 = context.getString(R.string.Sympathetic1);
		} else if (hrv <2.0 & hrv > 1.0) {
			asser1 = context.getString(R.string.Sympathetic2);
		} else if (hrv >= 2.0 ) {
			asser1 = context.getString(R.string.Sympathetic3);
		}
		return  asser1;
	}

	// 抗压能力

	public static String getCompression(int[] HRV_des, Context context) {
		String asser4 = "";
		String account=SharePreferenceUtils.getSpString(SharePreferenceUtils.KEY_PHONE);
		UserInfo userInfo= UserInfoDaoManager.getUser(account);
		int gender=userInfo==null?0:userInfo.getGender();
		if (HRV_des[3] <= 30) {
			asser4 = gender==1?context.getString(R.string.Compression1_female):context.getString(R.string.Compression1_male);

		} else if (HRV_des[3] <= 70 & HRV_des[3] > 30) {
			asser4 = gender==1?context.getString(R.string.Compression2_female):context.getString(R.string.Compression2_male);
		} else if ( HRV_des[3] >= 70) {
			asser4 = gender==1?context.getString(R.string.Compression3_female):context.getString(R.string.Compression3_male);
		}
		return asser4;
	}

	// 身体压力
	public static String getBody_pressure(int[] HRV_des, Context context) {
		String asser3 = "";
		if (HRV_des[1] <= 25) {
			asser3 = context.getString(R.string.body_pressure1);
		} else if (HRV_des[1] <= 50 & HRV_des[1] > 25) {
			asser3 = context.getString(R.string.body_pressure2);
		} else if (HRV_des[1] > 50) {
			asser3 = context.getString(R.string.body_pressure3);
		}
		return asser3;
	}

	// 心理压力
	public static String getMental_pressure(int[] HRV_des, Context context) {
		String asser2 = "";
		if (HRV_des[0] <= 30) {

			asser2 = context.getString(R.string.mental_pressure1);
		} else if (HRV_des[0] <= 70 & HRV_des[0] > 30) {

			asser2 = context.getString(R.string.mental_pressure2);
		} else if (HRV_des[0] <= 100 & HRV_des[0] > 70) {

			asser2 = context.getString(R.string.mental_pressure3);
		}
		return asser2;
	}
	
	public static String getHeartAgeAdvice(int[] HRV_des, Context context){
		String tips="";
		String account=SharePreferenceUtils.getSpString(SharePreferenceUtils.KEY_PHONE);
		UserInfo userInfo= UserInfoDaoManager.getUser(account);
		int realAge=25;
		int age=HRV_des[4];
		int maxAge=0;
		int minAge=0;
		if(age/2<=2){
			maxAge=30;
			minAge=0;
		}else if(age>2&&age<=4){
			maxAge=60;
			minAge=30;
		}else{
			maxAge=150;
			minAge=60;
		}
		if(realAge<minAge){
			tips=context.getResources().getString(R.string.heartAge3);
		}else if(realAge>=minAge&&age<maxAge){
			tips=context.getResources().getString(R.string.heartAge1);
		}else if(realAge>=maxAge){
			tips=context.getResources().getString(R.string.heartAge2);
		}
		return tips;
	}
	
	public static String getHrvReportTips(float hrv,int[] HRV_des, Context context){
		return getSympathetic(hrv, context)+getMental_pressure(HRV_des, context)
				+getBody_pressure(HRV_des, context)+getCompression(HRV_des, context)
				+getHeartAgeAdvice(HRV_des,context);
	}
}
